<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset=utf8>
</head>
<body>
  
     <form name="addform" action="1.php" method="post" onsubmit="return checkForm()">
        <table>
            <tr>
                <td>邮箱: </td>
                <td><input type="text" name="email"></td>
            </tr>
            <tr>
                <td>用户名: </td>
                <td><input type="text" name="user"></td>
            </tr>
            <tr>
                <td>密码: </td>
                <td><input type="password" name="pass"></td>
            </tr>
            <tr>
                <td>确认密码: </td>
                <td><input type="password" name="repass"></td>
            </tr>
            <tr>
                <td></td>
                <td><button type="submit">注册</button></td>
            </tr>
        </table>
    </form>

    <script>
      function checkForm()
      {
        var email = document.addform.email.value;

        if(email.match(/^[\w\.-]+@\w+(\.\w){1,3}$/)===null)
        {
          alert('邮箱格式错误');
          return false;
        }

        var user = document.addform.user.value;
        if(! /^\w{6,19}$/.test(user) )
        {
          alert('用户名格式错误');
          return false;
        }

        var pass = document.addform.pass.value;
        if(pass.length<6||pass.length>18)
        {
          alert('密码长度不对');
          return false;
        }

        var repass = document.addform.repass.value;
        if(repass!==pass)
        {
          alert('两次密码不一致');
          return false;
        }


        return true;
      }
      

    </script>


    
</body>
</html>